<?php

namespace Admin;

/**
 * 数据层
 */
class AdminDAOModel extends \DAO\DAOBase
{
    /**
     * 状态配置
     *
     * @var array
     */
    public $statusConfig = array(
        "1" => array("name" => "正常"),
        "2" => array("name" => "禁用"),
    );

    /**
     * 通过邮箱查找用户
     *
     * @param string $email
     * @return mixed
     */
    public function findAdminByEmail($email)
    {
        $result = $this->fetchAll(null, array("admin_email" => $email), null, 1);
        if ($result) {
            return $result[0];
        }
        return array();
    }

    /**
     * 构造方法
     */
    public function __construct()
    {
        $this->mysqlDAO = AdminMysqlModel::getInstance();
    }

    /**
     * 类实例
     *
     * @var \Admin\AdminDAOModel
     */
    private static $_instance = null;

    /**
     * 获取类实例
     *
     * @return \Admin\AdminDAOModel
     */
    public static function getInstance()
    {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }
}
